package tn.orange.canreminder.adapter;

import java.util.List;

import tn.orange.canreminder.R;
import tn.orange.canreminder.model.PlacesCategory;
import android.content.Context;
import android.location.Location;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PlaceCategoryAdapter extends BaseAdapter {

	private Context context;
	private List<PlacesCategory> categories;
	private LayoutInflater mInflater;

	public PlaceCategoryAdapter(Context context, List<PlacesCategory> categories) {
		super();
		mInflater = LayoutInflater.from(context);
		this.context = context;
		this.categories = categories;

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return categories.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return categories.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {

		ViewHolder holder;

		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_list, null);
			holder = new ViewHolder();

			holder.nom = (TextView) convertView
					.findViewById(R.id.place_category_nom);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		PlacesCategory category = categories.get(position);
		holder.nom.setText(category.getName());
		return convertView;
	}

	static class ViewHolder {
		TextView nom;
		ImageView image;

	}

}
